'''
    1.封装充值模块对应接口
'''
import app


class RechargeApi:

    def __init__(self, session):
        # 接收session对象的变量
        self.session = session
        self.url_recharge_verify_code = app.BASE_HOST + "/common/public/verifycode/{}"
        self.url_recharge = app.BASE_HOST + "/trust/trust/recharge"

    # 获取充值验证码接口
    def get_recharge_verify_code(self, r):
        return self.session.get(url=self.url_recharge_verify_code.format(r))

    # 充值接口
    def recharge(self, amount, valicode, paymentType="chinapnrTrust", formStr="reForm"):
        # 定义一个字典变量，用来接收请求体数据
        data_form = {"amount": amount, "valicode": valicode, "paymentType": paymentType, "formStr": formStr}
        return self.session.post(url=self.url_recharge, data=data_form)

    # 第三方充值接口
    def third_recharge(self, url, data_dict):
        return self.session.post(url=url, data=data_dict)
